/////////////////////////////////////////////////////////////////////////////////////
// Header Protection
#ifndef _PROCESS_H_
#define _PROCESS_H_

/////////////////////////////////////////////////////////////////////////////////////
// Derived classes are run on an independent thread.
class ABCProcess
{
protected:     // methods

	ABCProcess() : m_hThread(CE_NULL), m_bRunning(CE_FALSE), m_uiFrameRate(0) { }
	virtual ~ABCProcess() = 0 { }

	// Start running the thread at the given FPS.
	// _uiFrameRate: int_t - the number of ticks per second, 0 for as fast as 
	//     possible.
	void StartProcess( uint_t _uiFrameRate );

	// Stop running the thread.
	void StopProcess();

	// This pure virtual method is called just after the thread is created.
	virtual void ProcessBegin() = 0;

	// This pure virtual method is called at the interval given 
	//     by the current frame rate.
	// _fTime: float_t - the time, in seconds, that has elapsed since the last tick
	virtual void ProcessTick( float_t _fTime ) = 0;

	// This pure virtual method is called just before the thread is destroyed.
	virtual void ProcessEnd() = 0;

private:    // thread procedure
	static uint_t __stdcall ThreadProc( void * _pProcess );

private:    // data
	mutex_t m_DataMutex;
	HANDLE  m_hThread;
	bool_t  m_bRunning;
	int_t   m_uiFrameRate;

private:    // dummy definitions
	ABCProcess( ABCProcess const & );
	ABCProcess & operator =( ABCProcess const & );
};

/////////////////////////////////////////////////////////////////////////////////////
// Header Protection
#endif // _PROCESS_H_
